package cn.whale.pay.dto;


import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/*http://localhost:1030/alipay/return?
"gmt_create" -> {String[1]@10494}
"charset" -> {String[1]@10498}
"gmt_payment" -> {String[1]@10500}
"notify_time" -> {String[1]@10502}
"subject" -> {String[1]@10504}
"sign" -> {String[1]@10506}
"buyer_id" -> {String[1]@10508}
"invoice_amount" -> {String[1]@10510}
"version" -> {String[1]@10512}
"notify_id" -> {String[1]@10514}
"fund_bill_list" -> {String[1]@10516}
"notify_type" -> {String[1]@10518}
"out_trade_no" -> {String[1]@10520}
"total_amount" -> {String[1]@10522}
"trade_status" -> {String[1]@10524}
"trade_no" -> {String[1]@10526}
"auth_app_id" -> {String[1]@10528}
"receipt_amount" -> {String[1]@10530}
"point_amount" -> {String[1]@10532}
"app_id" -> {String[1]@10534}
"buyer_pay_amount" -> {String[1]@10536}
"sign_type" -> {String[1]@10538}
"seller_id" -> {String[1]@10540} */
@Data
public class AlipayNotifyDto {
    public static final String WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
    public static final String TRADE_CLOSED = "TRADE_CLOSED";
    public static final String TRADE_SUCCESS = "TRADE_SUCCESS";
    public static final String TRADE_FINISHED = "TRADE_FINISHED";
    private String charset;
    private String gmt_create;
    private String gmt_payment;
    private String notify_time;
    private String subject;
    private String sign;
    private String buyer_id;
    private String invoice_amount;
    private String version;
    private String notify_id;
    private String fund_bill_list;
    private String notify_type;
    private String out_trade_no;
    private String total_amount;
    //交易状态：WAIT_BUYER_PAY（交易创建，等待买家付款）、TRADE_CLOSED（未付款交易超时关闭，或支付完成后全额退款）、TRADE_SUCCESS（交易支付成功）、TRADE_FINISHED（交易结束，不可退款）
    private String trade_status;
    private String trade_no;
    private String auth_app_id;
    private String receipt_amount;
    private String point_amount;
    private String app_id;
    private String buyer_pay_amount;
    private String sign_type;
    private String seller_id;
    private String code;
    private String msg;

    @JSONField(serialize = false)
    public boolean isTradeSuccess(){
        return this.trade_status.equals(TRADE_SUCCESS) || this.trade_status.equals(TRADE_FINISHED);
    }
    @JSONField(serialize = false)
    public boolean isTradeWit(){
        return this.trade_status.equals(WAIT_BUYER_PAY);
    }
    @JSONField(serialize = false)
    public boolean isTradeExpire(){
        return this.trade_status.equals(TRADE_CLOSED);
    }
}
